
<%@page import="Entities.*"%>
<%@page import="Helpers.*"%>
<%@page import="Hibernate.*"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Enquetes</title>
    </head>
    <body>
        
        <%
        String id = (String) request.getParameter("id");
        String naam = (String) request.getParameter("naam");
        if(naam == null){
                         RollenHelper helper = new RollenHelper();
                         Rollen rol = helper.getRol(Integer.parseInt(id));

 
        %>
        <form name="wijzigForm" method="POST" action="showRol.jsp" >
          <table border="1">
             <tr>
                 <input type="hidden" name="id" value="<%=rol.getId()%>">
                 <td>Naam: </td>
                 <td><%=rol.getNaam()%></td>
                 <td><input type="text" name="naam" value="<%=rol.getNaam()%>"></td>
             </tr>
          </table>
          <input type="submit" value="Wijzig">
        </form>
        <%
        }else{
               RollenHelper helper = new RollenHelper();
               Rollen rol = helper.getRol(Integer.parseInt(id));

               rol.setNaam(naam);
               helper.updateRol(rol);

               response.sendRedirect("showRol.jsp?id=" + rol.getId());
           }
        %>
        <a href="showRollen.jsp"> Terug </a>
    </body>
</html>